import React, { Component, Suspense } from 'react';
import { HashRouter as Router, Route, Switch } from 'react-router-dom'
import routes from "./index"

class RouterConfig extends Component {
    render() {
        return (
            <Suspense fallback={<div>loading......</div>}>
              <Router>
                <Switch>
                  {/* 
                  <Route path="" render={()=><Cmp></Cmp>}></Route>
                 */}
                  {
                    routes.map(route => {
                      return <Route exact={route.exact}
                        path={route.path} key={route.path}
                        render={(props) => <route.component {...props} {...route.routes}></route.component>}>
      
                      </Route>
                    })
                  }
                </Switch>
              </Router>
            </Suspense>
          );
    }
}

export default RouterConfig;
